<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>cshep2d</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 24/03/2004</div>
    <p>
      <b>cshep2d</b> - bidimensional cubic shepard (scattered) interpolation</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>tl_coef = cshep2d(xyz)</tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>xyz</b>
        </tt>: a n x 3 matrix of the (no gridded) interpolation points (the i th row given
               the (x,y) coordinates then the altitude z of the i th interpolation point)</li>
      <li>
        <tt>
          <b>tl_coef</b>
        </tt>: a tlist scilab structure (of type cshep2d)</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    This function is useful to define a 2d interpolation function when the interpolation
    points are not on a grid (you may use it in this case but <a href="splin2d.htm">
        <tt>
          <b>splin2d</b>
        </tt>
      </a> is
    better for that purpose). The interpolant is a cubic shepard one and is
    a C2 (twice continuously differentiable) bivariate function <em>s(x,y)</em>
    such that : <em>s(xi,yi)=zi</em> for all <em>i=1,..,n</em> ( <em>(xi,yi,zi)</em>
    being the i th row of <tt>
        <b>xyz</b>
      </tt>).
    </p>
    <p>
    The evaluation of  <em>s</em> at some points must be done by the <a href="eval_cshep2d.htm">
        <tt>
          <b>eval_cshep2d</b>
        </tt>
      </a> 
    function.
    </p>
    <h3>
      <font color="blue">Remark</font>
    </h3>
    <dl>
      <p>
    The function works if <b>n &gt;= 10</b>, if the nodes are not all colinears
    (i.e. the <em>(x,y)</em> coordinates of the interpolation points are not 
    on the same straight line), and if there is no duplicate nodes (i.e. 2 or more
    interpolation points with the same <em>(x,y)</em> coordinates). An error is
    issued if these conditions are not respected.
    </p>
    </dl>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>
// interpolation of cos(x)cos(y) with randomly choosen interpolation points
n = 150; // nb of interpolation points
xy = grand(n,2,"unf",0,2*%pi);
z = cos(xy(:,1)).*cos(xy(:,2));
xyz = [xy z];
tl_coef = cshep2d(xyz);

// evaluation on a grid
m = 30;
xx = linspace(0,2*%pi,m);
[X,Y] = ndgrid(xx,xx);
Z = eval_cshep2d(X,Y, tl_coef);
xbasc()
plot3d(xx,xx,Z,flag=[2 6 4])
param3d1(xy(:,1),xy(:,2),list(z,-9), flag=[0 0])
xtitle("Cubic Shepard Interpolation of cos(x)cos(y) with randomly choosen interpolation points")
legends("interpolation points",-9,1)
xselect()
 </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="splin2d.htm">
        <tt>
          <b>splin2d</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="eval_cshep2d.htm">
        <tt>
          <b>eval_cshep2d</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Authors</font>
    </h3>
    <dl>
      <dd>
        <b></b> Robert J. Renka</dd>
      <dd>
        <b></b> B. Pincon (scilab interface)</dd>
    </dl>
  </body>
</html>
